<?php

/**
 * Description of SiteLogin
 *
 * @author LongLT
 */
Yii::import('application.models.Comments');
class CommentPost extends CWidget {
	public $id 		= null;
	public $ajax 	= null;
	public $info	= null;
    public function run() {

		$postId		= $this->id;
		$ajax		= $this->ajax;
		$info		= $this->info;
		if($ajax){
			$this->render('_commentForm', array('isReply' => true));
		}
		else if (isset($info)) {
			$this->render('_commentReply', $info);
		}
		else {
			$model		= new Comments;
			$comments	= Comments::model()->findAllByAttributes(array('post_id' => $postId, 'parent_id' => null, 'status' => 1), array('order' => 'create_at DESC'));
			$this->render('CommentPost', compact('comments', 'model', 'postId'));
		}
    }

}
